package priv.pront.code.lanqiao.competition.course.date0327;

import java.util.*;

public class 教室排课 {
    static int na, nb, nc, nd;
    static Set<String> set = new TreeSet<>();
    static List<Integer> list = new ArrayList<>();
    static int[] arr = {120, 40, 85, 50, 100, 140, 70, 100};
    static boolean[] visited = new boolean[8];
    static int[] size = new int[4];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        na = scanner.nextInt();
        nb = scanner.nextInt();
        nc = scanner.nextInt();
        nd = scanner.nextInt();
        size[0] = na;
        size[1] = nb;
        size[2] = nc;
        size[3] = nd;
        backtracking();
        if (set.size() == 0) {
            System.out.println(-1);
            return;
        }
        for (String s : set) {
            System.out.println(s);
        }
    }

    private static void backtracking(){
        if (list.size() == 4) {
            set.add(toString(list));
            return;
        }
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] < size[list.size()] || visited[i]) {
                continue;
            }
            list.add(i + 1);
            visited[i] = true;
            backtracking();
            list.remove(list.size() - 1);
            visited[i] = false;
        }
    }

    private static String toString(List<Integer> list) {
        String ans = "";
        String s = list.toString();
        ans = s.substring(1, s.length() - 1);
        return ans.replaceAll(",", "");
    }
}
